package com.example.kaoshi;

/**
 * Created by Quincy on 2018/10/11.
 */

import java.util.ArrayList;
        import java.util.List;
        import java.util.Scanner;

public class Test33 {

    static boolean justic(int a){
        switch (a){
            case 0:
                return true;
            case 3:
                return true;
            case 6:
                return true;
            default:
                return false;
        }
    }

    public static void main(String[] args){
        List<Integer> iList = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        for (int i = 0; i < num; i++){

            iList.add(sc.nextInt());
        }
//        String mStr = sc.nextLine();
//        String[] mStrs = mStr.split(" ");
//        for (String str:mStrs){
//            iList.add(Integer.valueOf(str));
//        }
        int n = 1;
        int acc = 0;
        for (int i = 1;i<iList.size();i++){
            if(justic(iList.get(i))&&(iList.get(i) != (iList.get(i - n)))){
                if(justic(iList.get(i - n))){
                    n+=2;
                    acc++;
                }else {
                    n = 1;
                }
            }

        }
        System.out.println(num - acc*2);
    }
}
